﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ForkCarRelationManager.Business;
namespace ForkCarRelationManager
{
    public partial class RemindDetailForm : Form
    {
        private int remindID=0;

        RemindBI remindBI;
        public RemindDetailForm(int remindID)
        {
            InitializeComponent();
            this.remindID = remindID;
          string  datetime = DateTime.Now.ToString("yyyy/M/d");
          remindBI = new RemindBI(datetime, 100000);
          initForm();
        }
        private void initForm()
        {
            if (remindID != 0)
            {
                DataTable remindTable = remindBI.Getdetailsbyrid(remindID);
                TBclientName.Text = remindTable.Rows[0]["ClientName"].ToString();
                TBconname.Text = remindTable.Rows[0]["ContactName"].ToString();
                TBconphone.Text = remindTable.Rows[0]["ContactPhone"].ToString();
                TBdate.Text = remindTable.Rows[0]["MaintenDate"].ToString().Replace("0:00:00", "");
                TBmaintenType.Text = remindTable.Rows[0]["维修类型"].ToString();
                TBnum.Text = remindTable.Rows[0]["DeviceNum"].ToString();
                TBremindtext.Text = remindTable.Rows[0]["RemindContext"].ToString();
                TPtime.Text = remindTable.Rows[0]["RemindTime"].ToString();
            }
        }
        private void RemindDetailForm_Load(object sender, EventArgs e)
        {

        }

        private void Btn_save_Click(object sender, EventArgs e)
        {
            string datetime = TPtime.Text.Replace("年", "/").Replace("月", "/").Replace("日", "").Trim();//必要
            string remindcontext = TBremindtext.Text.Trim();
            if (remindcontext != "" && datetime != "")
            {
                if(remindBI.updatedetailbyid(remindID,datetime,remindcontext))
                {
                    MessageBox.Show("修改成功");
                this.DialogResult = DialogResult.Yes;
                }
                else
                    MessageBox.Show("修改失败");
            }
            else
                MessageBox.Show("打星号的必填项值不能为空");
        }
    }
}
